package nowcoder.written_examination.pdd;

import java.util.*;

/**
 *
 * @author fance
 * @date 18-6-26 上午6:11
 */
public class Main {
   /* public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int step = 0;
        }
    }
}*/
    /*public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int step = 0;
            int remain = n;
            while (remain > 0) {
                int[] lis = lisLen(a);
                int[] lisRev = lisLenRev(a);
                if (findMax(lis) > findMax(lisRev)) {
                    int maxLen = 0;
                    int index = 0;
                    for (int i = 0; i < lis.length; i++) {
                        if (lis[i] > maxLen) {
                            maxLen = lis[i];
                            index = i;
                        }
                    }
                    remain -= maxLen;
                    int head = index;
                    for (int i =  index; i>= 0; i--) {
                        if (a[i] < a[index] && lis[i] == lis[index] - 1) {
                            a[i] = -1;
                            index = i;
                        }
                    }
                    a[head] = -1;
                } else {
                    int maxLen = 0;
                    int index = 0;
                    for (int i = 0; i < lisRev.length; i++) {
                        if (lisRev[i] > maxLen) {
                            maxLen = lisRev[i];
                            index = i;
                        }
                    }
                    remain -= maxLen;
                    int head = index;
                    for (int i =  index; i>= 0; i--) {
                        if (a[i] < a[index] && lisRev[i] == lisRev[index] - 1) {
                            a[i] = -1;
                            index = i;
                        }
                    }
                    a[head] = -1;
                }
                step++;
            }
            System.out.println(step);
        }
    }
    public static int[] lisLen(int[] a) {
        if (a == null || a.length == 0) {
            return null;
        }
        int[] dp = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            if (a[i] == -1) {
                continue;
            }
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (a[i] > a[j]) {
                    dp[i] = Math.max(dp[i],dp[j] + 1);
                }
            }
        }
        return dp;
    }
    public static int[] lisLenRev(int[] a) {
        if (a == null || a.length == 0) {
            return null;
        }
        int[] dp = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            if (a[i] == -1) {
                continue;
            }
            dp[i] = 1;
            for (int j = 0; j < i; j++) {
                if (a[i] < a[j]) {
                    dp[i] = Math.max(dp[i],dp[j] + 1);
                }
            }
        }
        return dp;
    }
    public static int findMax(int[] a) {
        int max = 0;
        for (int i = 0; i < a.length; i++) {
            if (a[i] > max) {
                max = a[i];
            }
        }
        return max;
    }
}*/
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String str = in.nextLine();
            String[] begin = str.trim().split(" ");
            int n = Integer.parseInt(begin[0]);
            int num = Integer.parseInt(begin[1]);
            Map<Integer,List<Integer>> map = new LinkedHashMap<>();
            for (int i = 0; i < n; i++) {
               List<Integer> list = new ArrayList<>();
               String s = in.nextLine();
               String[] strings = s.trim().split(" ");
                for (int j = 0; j < strings.length; j++) {
                   list.add(Integer.valueOf(strings[j]));
                }
                map.put(i,list);
            }

            List<Integer> list = map.get(num);
            int cnt = 0;
            int res = 0;
            for (Map.Entry<Integer,List<Integer>> entry : map.entrySet()) {
                if (entry.getKey() == num) {
                    continue;
                }
                List<Integer> cur = entry.getValue();
                int curLen = 0;
                for (int i = 0; i < list.size(); i++) {
                    for (int j = 0; j < cur.size(); j++) {
                        if (Objects.equals(list.get(i), cur.get(j))) {
                            curLen++;
                        }
                    }
                }
                if (curLen > cnt) {
                    res = entry.getKey();
                }
            }
            System.out.println(res);
        }
    }
}
   /* public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.next();
            int cnt = 0;
            for (int i = 1; i < s.length(); i++) {
                String left = s.substring(0,i);
                String right = s.substring(i,s.length());
                if (isValid(left) && isValid(right)) {
                    cnt++;
                }
                List<String> leftList = insert(left);
                List<String> rightList = insert(right);
                int leftValid = 0;
                for (int j = 0; j < leftList.size(); j++) {
                    if (isValid(leftList.get(j))) {
                        leftValid++;
                    }
                }
                int rightValid = 0;
                for (int j = 0; j < rightList.size(); j++) {
                    if (isValid(rightList.get(j))) {
                        rightValid++;
                    }
                }

                cnt += leftValid * rightValid;
                if (isValid(left)) {
                    cnt += rightValid;
                }
                if (isValid(right)) {
                    cnt += leftValid;
                }
            }
            System.out.println(cnt);
        }
    }
    public static List<String> insert(String s) {
        List<String> list = new ArrayList<>();
        for (int i = 1; i < s.length(); i++) {
            list.add(s.substring(0,i) + "." + s.substring(i));
        }
        list.add("." + s);
        list.add(s + ".");
        return list;
    }
    public static boolean isValid(String s) {
        if (s.startsWith(".") || s.endsWith(".")) {
            return false;
        } else {
            if (s.contains(".")) {
                if (s.endsWith("0")) {
                    return false;
                } else if (s.startsWith("0.")) {
                    return true;
                }
            } else if (s.equals("0")) {
                return true;
            } else {
                if (s.charAt(0) == '0') {
                    return false;
                }
            }
        }
        return true;

    }
}*/
    /*public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            String s = in.next();
            int len = s.length();
            int n = len / 4 + 1;
            String[][] map = new String[n][n];
            int tc = 0,tr = 0,dr = n - 1,dc = n - 1;
            int index = 0;
            int curC = 0,curR = 0;
            while (curC != dc) {
                map[curR][curC] = String.valueOf(s.charAt(index++));
                curC++;
            }
            while (curR != dr) {
                map[curR][curC] = String.valueOf(s.charAt(index++));
                curR++;
            }
            while (curC != tc) {
                map[curR][curC] = String.valueOf(s.charAt(index++));
                curC--;
            }
            while (curR != tr) {
                map[curR][curC] = String.valueOf(s.charAt(index++));
                curR--;
            }

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (map[i][j] == null) {
                        System.out.print(" ");
                    } else {
                        System.out.print(map[i][j]);
                    }
                }
                System.out.println();
            }
        }
    }
}*/

